<template>
    <div class="newsInfo-container">
        <h3>{{newsInfo.title}}</h3>
        <p class="subtext">
            <span>发表时间：{{newsInfo.add_time | dateFormat}}</span>
            <span>点击：{{newsInfo.click}}次</span>
        </p>
        <hr>
        <div class="content" v-html="newsInfo.content"></div>
        <comment-box :id="this.id"></comment-box>
    </div>
</template>

<script>
    import { Toast } from 'mint-ui'
    import comment from '../subcomponents/comment.vue'
    export default {
        data() {
            return {
                newsInfo:{},
                id:this.$route.params.id
            }
        },
        created(){
            this.getListInfo();
        },
        methods:{
            getListInfo(){
                this.$http.get('http://www.liulongbin.top:3005/api/getnew/' + this.id).then(result =>{
                    var result = result.body;
                    if(result){
                        this.newsInfo = result.message[0];
                    }
                },result =>{
                    Toast('获取数据失败');

                })
            }
        },
        components:{
            'comment-box':comment
        }
    }
</script>

<style scoped>
    .newsInfo-container{
        padding: 0 4px;
    }

    .newsInfo-container h3{
        font-size:14px;
        color:red;
        text-align: center;
        margin: 15px 0;
    }
    .newsInfo-container .subtext{
        font-size: 13px;
        color:#226aff;
        display: flex;
        justify-content: space-between;
    }
</style>